package pacBioSimple;

import pacBiopackage.GetOpt;

public class ApplySoapResultMain {
	public static void main(String[] args) {
		GetOpt go = new GetOpt(args, "o:a:b:h");
		go.optErr = true;
		int ch = -1;
		
		// process options in command line arguments
		// Set default values
		boolean usagePrint = false;                 
		String filenameSoap = "";
		String filenamePacBio = "";
		String filenameOutput="output.txt";
		
		while ((ch = go.getopt()) != GetOpt.optEOF) 
		{
		    if ((char)ch == 'h') {
		       usagePrint = true;
		    }
		    else if((char)ch =='o')
		    {
		    	filenameOutput = go.optArgGet();
		    }
		    else if((char)ch =='a')
		    {
		    	filenameSoap=go.optArgGet();
		    }
		    else if((char)ch =='b')
		    {
		    	filenamePacBio=go.optArgGet();
		    }
		    else
		        System.exit(1);                     // undefined option
		}                                           // getopt() returns '?'
		
		if (usagePrint || filenameSoap.isEmpty()||filenamePacBio.isEmpty()) {
		    System.out.println("Usage: -a soap_result -b pacBioReads [ -o outputFile -h]"); //NOI18N
		    System.exit(0);
		}
		System.out.println("------------------------");
		System.out.println("Command line parameter settings:");
		System.out.println("-o " + filenameOutput); //NOI18N
		System.out.println("-a " + filenameSoap); //NOI18N	
		System.out.println("-b " + filenamePacBio); //NOI18N	
		System.out.println("------------------------");
		
		
		try
		{
			ReadSoapResult soapReader = new ReadSoapResult(filenameSoap);
			System.out.println("done with caching");
			ReadAndCorrectRead pacBioReads = new ReadAndCorrectRead(filenamePacBio, soapReader.getAlignmentR(), filenameOutput);
			pacBioReads.readAndCorrect();
			//soapReader.
		}
		catch(Exception e)
		{
			e.printStackTrace();
		}
	}
}
